<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>结算 - 阿里宝宝</title>
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/components.css">
    <link rel="stylesheet" href="css/responsive.css">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
</head>
<body>
    <!-- 顶部导航栏 -->
    <header class="header">
        <div class="container">
            <div class="header-content">
                <!-- Logo -->
                <div class="logo">
                    <a href="index.html">
                        <i class="fas fa-shopping-bag"></i>
                        <span>阿里宝宝</span>
                    </a>
                </div>

                <!-- 搜索框 -->
                <div class="search-box">
                    <input type="text" id="searchInput" placeholder="搜索商品...">
                    <button id="searchBtn"><i class="fas fa-search"></i></button>
                </div>

                <!-- 用户操作区 -->
                <div class="user-actions">
                    <div class="user-menu" id="userMenu">
                        <button class="user-btn" id="userBtn">
                            <i class="fas fa-user"></i>
                            <span id="userName">登录</span>
                        </button>
                        <div class="user-dropdown" id="userDropdown">
                            <div class="dropdown-content">
                                <a href="#" id="loginLink">登录</a>
                                <a href="#" id="registerLink">注册</a>
                                <a href="#" id="profileLink" style="display: none;">个人中心</a>
                                <a href="#" id="ordersLink" style="display: none;">我的订单</a>
                                <a href="#" id="logoutLink" style="display: none;">退出登录</a>
                            </div>
                        </div>
                    </div>
                    
                    <div class="cart-icon" id="cartIcon">
                        <a href="cart.html">
                            <i class="fas fa-shopping-cart"></i>
                            <span class="cart-count" id="cartCount">0</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <!-- 面包屑导航 -->
    <nav class="breadcrumb">
        <div class="container">
            <ol class="breadcrumb-list">
                <li><a href="index.html">首页</a></li>
                <li><a href="cart.html">购物车</a></li>
                <li>结算</li>
            </ol>
        </div>
    </nav>

    <!-- 结算主要内容 -->
    <main class="checkout-main">
        <div class="container">
            <div class="checkout-content">
                <!-- 收货地址 -->
                <div class="checkout-section">
                    <div class="section-header">
                        <h2><i class="fas fa-map-marker-alt"></i>收货地址</h2>
                        <button class="btn btn-outline btn-sm" id="addAddressBtn">添加新地址</button>
                    </div>
                    
                    <div class="address-list" id="addressList">
                        <!-- 地址列表将通过JavaScript动态生成 -->
                    </div>
                    
                    <div class="address-form" id="addressForm" style="display: none;">
                        <form id="newAddressForm">
                            <div class="form-row">
                                <div class="form-group">
                                    <label for="recipientName">收件人姓名</label>
                                    <input type="text" id="recipientName" name="recipientName" required>
                                </div>
                                <div class="form-group">
                                    <label for="recipientPhone">联系电话</label>
                                    <input type="tel" id="recipientPhone" name="recipientPhone" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="address">详细地址</label>
                                <textarea id="address" name="address" rows="3" required placeholder="请输入详细的收货地址"></textarea>
                            </div>
                            <div class="form-actions">
                                <button type="submit" class="btn btn-primary">保存地址</button>
                                <button type="button" class="btn btn-outline" id="cancelAddressForm">取消</button>
                            </div>
                        </form>
                    </div>
                </div>

                <!-- 商品清单 -->
                <div class="checkout-section">
                    <div class="section-header">
                        <h2><i class="fas fa-shopping-cart"></i>商品清单</h2>
                    </div>
                    
                    <div class="order-items" id="orderItems">
                        <!-- 订单商品将通过JavaScript动态生成 -->
                    </div>
                </div>

                <!-- 配送方式 -->
                <div class="checkout-section">
                    <div class="section-header">
                        <h2><i class="fas fa-truck"></i>配送方式</h2>
                    </div>
                    
                    <div class="shipping-options">
                        <div class="shipping-option active" data-shipping="standard">
                            <div class="option-info">
                                <h3>标准配送</h3>
                                <p>3-5个工作日送达</p>
                            </div>
                            <div class="option-price">¥15.00</div>
                        </div>
                        <div class="shipping-option" data-shipping="express">
                            <div class="option-info">
                                <h3>快速配送</h3>
                                <p>1-2个工作日送达</p>
                            </div>
                            <div class="option-price">¥25.00</div>
                        </div>
                    </div>
                </div>

                <!-- 支付方式 -->
                <div class="checkout-section">
                    <div class="section-header">
                        <h2><i class="fas fa-credit-card"></i>支付方式</h2>
                    </div>
                    
                    <div class="payment-options">
                        <div class="payment-option active" data-payment="alipay">
                            <i class="fab fa-alipay"></i>
                            <span>支付宝</span>
                        </div>
                        <div class="payment-option" data-payment="wechat">
                            <i class="fab fa-weixin"></i>
                            <span>微信支付</span>
                        </div>
                        <div class="payment-option" data-payment="bank">
                            <i class="fas fa-university"></i>
                            <span>银行卡</span>
                        </div>
                    </div>
                </div>

                <!-- 订单备注 -->
                <div class="checkout-section">
                    <div class="section-header">
                        <h2><i class="fas fa-sticky-note"></i>订单备注</h2>
                    </div>
                    
                    <div class="order-notes">
                        <textarea id="orderNotes" placeholder="如有特殊要求，请在此说明..."></textarea>
                    </div>
                </div>
            </div>

            <!-- 订单汇总 -->
            <div class="order-summary">
                <div class="summary-header">
                    <h2>订单汇总</h2>
                </div>
                
                <div class="summary-content">
                    <div class="summary-item">
                        <span class="label">商品总价：</span>
                        <span class="value" id="subtotal">¥0.00</span>
                    </div>
                    <div class="summary-item">
                        <span class="label">运费：</span>
                        <span class="value" id="shippingFee">¥15.00</span>
                    </div>
                    <div class="summary-item discount" id="discountItem" style="display: none;">
                        <span class="label">游戏折扣：</span>
                        <span class="value discount-amount">-¥0.00</span>
                    </div>
                    <div class="summary-item total">
                        <span class="label">应付总额：</span>
                        <span class="value" id="totalAmount">¥0.00</span>
                    </div>
                </div>
                
                <div class="checkout-actions">
                    <button class="btn btn-outline btn-large" id="playGameBtn">
                        <i class="fas fa-gamepad"></i>
                        玩折扣游戏
                    </button>
                    <button class="btn btn-primary btn-large" id="submitOrderBtn">
                        <i class="fas fa-credit-card"></i>
                        提交订单
                    </button>
                </div>
            </div>
        </div>
    </main>

    <!-- 页脚 -->
    <footer class="footer">
        <div class="container">
            <div class="footer-content">
                <div class="footer-section">
                    <h3>关于我们</h3>
                    <p>阿里宝宝致力于为用户提供优质的购物体验</p>
                </div>
                <div class="footer-section">
                    <h3>客户服务</h3>
                    <ul>
                        <li><a href="#">帮助中心</a></li>
                        <li><a href="#">联系客服</a></li>
                        <li><a href="#">意见反馈</a></li>
                    </ul>
                </div>
                <div class="footer-section">
                    <h3>购物指南</h3>
                    <ul>
                        <li><a href="#">购物流程</a></li>
                        <li><a href="#">配送说明</a></li>
                        <li><a href="#">退换货政策</a></li>
                    </ul>
                </div>
                <div class="footer-section">
                    <h3>关注我们</h3>
                    <div class="social-links">
                        <a href="#"><i class="fab fa-weixin"></i></a>
                        <a href="#"><i class="fab fa-weibo"></i></a>
                        <a href="#"><i class="fab fa-qq"></i></a>
                    </div>
                </div>
            </div>
            <div class="footer-bottom">
                <p>&copy; 2024 阿里宝宝电商平台. All rights reserved.</p>
            </div>
        </div>
    </footer>

    <!-- 折扣游戏弹窗 -->
    <div class="modal" id="discountGameModal">
        <div class="modal-content game-modal">
            <div class="modal-header">
                <h2>🎮 折扣游戏</h2>
                <span class="close" id="closeGameModal">&times;</span>
            </div>
            <div class="modal-body">
                <div class="game-container">
                    <div class="game-info">
                        <h3>贪吃蛇游戏</h3>
                        <p>控制蛇吃食物，获得分数换取折扣！</p>
                        <div class="score-display">
                            <span>当前分数: </span>
                            <span id="gameScore">0</span>
                        </div>
                        <div class="discount-info">
                            <span>可获得折扣: </span>
                            <span id="discountPercent">0%</span>
                        </div>
                    </div>
                    <div class="game-board">
                        <canvas id="gameCanvas" width="400" height="400"></canvas>
                        <div class="game-controls">
                            <button id="startGame" class="btn btn-primary">开始游戏</button>
                            <button id="pauseGame" class="btn btn-secondary" disabled>暂停</button>
                            <button id="resetGame" class="btn btn-outline">重新开始</button>
                        </div>
                        <div class="game-instructions">
                            <p>使用方向键控制蛇的移动</p>
                            <p>吃到食物获得分数，避免撞墙或撞到自己</p>
                        </div>
                    </div>
                </div>
                <div class="game-result" id="gameResult" style="display: none;">
                    <h3>游戏结束！</h3>
                    <p>最终分数: <span id="finalScore">0</span></p>
                    <p>获得折扣: <span id="finalDiscount">0%</span></p>
                    <button id="applyDiscount" class="btn btn-success">应用折扣</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 订单成功模态框 -->
    <div class="modal" id="orderSuccessModal">
        <div class="modal-content">
            <div class="modal-header">
                <h2><i class="fas fa-check-circle"></i>订单提交成功</h2>
            </div>
            <div class="modal-body">
                <div class="order-success-content">
                    <div class="success-icon">
                        <i class="fas fa-check-circle"></i>
                    </div>
                    <h3>感谢您的购买！</h3>
                    <p>您的订单已提交成功，我们将尽快为您处理。</p>
                    <div class="order-info">
                        <div class="info-item">
                            <span class="label">订单编号：</span>
                            <span class="value" id="orderNumber">-</span>
                        </div>
                        <div class="info-item">
                            <span class="label">预计送达：</span>
                            <span class="value" id="estimatedDelivery">-</span>
                        </div>
                    </div>
                    <div class="success-actions">
                        <button class="btn btn-primary" id="viewOrderBtn">查看订单</button>
                        <button class="btn btn-outline" id="continueShoppingBtn">继续购物</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 加载提示 -->
    <div class="loading" id="loading">
        <div class="loading-spinner"></div>
        <p>加载中...</p>
    </div>

    <!-- 通知提示 -->
    <div class="notification" id="notification">
        <div class="notification-content">
            <i class="fas fa-check-circle"></i>
            <span id="notificationText">操作成功</span>
        </div>
    </div>

    <!-- JavaScript文件 -->
    <script src="js/api.js"></script>
    <script src="js/auth.js"></script>
    <script src="js/cart.js"></script>
    <script src="js/product.js"></script>
    <script src="js/game.js"></script>
    <script src="js/checkout.js"></script>
</body>
</html>
